#include <bits/stdc++.h>
using namespace std;
long long n,m,ans,T,sum;
long long l,upv,d[100005],v[100005],a[100005],p[100005],book[100005],last[100005];
bool zhen = false;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin >> T;
    for (int q = 1;q <= T;q++)
    {
        cin >> n >> m >> l >> upv;
        for (int i = 1;i <= n;i++)
        {
            cin >> d[i] >> v[i] >> a[i];
        }
        for (int i = 1;i <= m;i++)
        {
            cin >> p[i];
        }
        for (int i = 1;i <= n;i++)
        {
            if (a[i] > 0)
            {
                if (v[i] *v[i]+2 *a[i] *(p[m]-d[i]) >upv*upv)
                    ans++;
                    book[i] = 1;

            }
            if (a[i] == 0)
            {
                if (v[i] > upv)
                {
                    ans++;
                    book[i] = 1;
                }
            }

        }
        cout << ans << endl;
        cout << 1;
    }

    return 0;
}
